From 5cd9d030828af745e833a9280031d298617a5a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 15 Apr 2017 15:46:07 +0100 Subject: glucometer: make the error fatal and more clear when setting an invalid date. --- glucometer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glucometer.py b/glucometer.py index 5d75bcb..dc5d78b 100755 --- a/glucometer.py +++ b/glucometer.py @@ -98,9 +98,11 @@ def main(): print(device.set_datetime()) elif args.set: try: - print(device.set_datetime(date_parser.parse(args.set))) + new_date = date_parser.parse(args.set) except ValueError: - print('%s: not a valid date' % args.set, file=sys.stderr) + logging.error('%s: not a valid date', args.set) + return 1 + print(device.set_datetime(new_date)) else: print(device.get_datetime()) elif args.action == 'zero': -- cgit v1.2.3